package com.hebeu.device.service.impl;


import com.hebeu.device.dao.DUserMapper;
import com.hebeu.device.pojo.DUser;
import com.hebeu.device.pojo.DUserExample;
import com.hebeu.device.service.LoginService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户逻辑层实现类
 * 样例
 */

@Service
public class LoginServiceImpl implements LoginService {

    @Resource
    private DUserMapper dUserMapper;


    @Override
    public DUser getDUser(String userName,String password) {

        DUserExample dUserExample = new DUserExample();
        DUserExample.Criteria criteria = dUserExample.createCriteria();
        //添加查询条件  用户名
        criteria.andUsernameEqualTo(userName);
        //密码
        criteria.andPasswordEqualTo(password);
        //执行查询语句
        List<DUser> dUserList = dUserMapper.selectByExample(dUserExample);
        //若查询结果条数大于0返回第一个数据，否则返回空
        return dUserList.size()==0?null:dUserList.get(0);
    }
}
